import {configureStore} from "@reduxjs/toolkit";
import userReducer, {userState} from "./userReducer";
import undoable, {excludeAction, StateWithHistory} from 'redux-undo'
import ComponentsReducer, {ComponentsStateType} from "./componentsReducer";
import pageInfoReducer, {PageInfoType} from "./pageinfoReducer";

export interface StoreState {
  user: userState,
  components: StateWithHistory<ComponentsStateType>,
  pageInfo: PageInfoType
}

const store = configureStore({
  reducer: {
    user: userReducer,
    // components: ComponentsReducer,
    components: undoable(ComponentsReducer, {
      limit: 20,
      filter: excludeAction([
        'components/resetComponent',
        'components/changeSelectedId',
        'components/selectPrevComponent',
        'components/selectNextComponent',
      ])
    }),
    //   页面设置信息
    pageInfo: pageInfoReducer
  }
})
export default store
